<template>
  <div class="maincontent">
    <el-form :inline="true" label-width="90px">
      <div class="maintitle">项目基本信息（市级项目）</div>
      <div class="formcontent">
        <div class="basicInformation">
          <span>项目名称：{{numData.projectInfoDTO.name}}</span>
          <span>项目编号：{{numData.projectInfoDTO.number}}</span>
          <span>项目级别：{{numData.projectInfoDTO.level === 0 ? '市级' : '区县级'}}</span>
          <span>图幅号：{{numData.projectInfoDTO.frameNumber}}</span>
        </div>
        <div class="basicInformation">
          <span>所属区县：{{numData.projectInfoDTO.district}}</span>
          <span>乡镇：{{numData.projectInfoDTO.countryside}}</span>
          <span>行政村：{{numData.projectInfoDTO.village}}</span>
        </div>
      </div>
      <div class="maintitle" style="margin:60px 0 30px 0;">建设信息</div>
      <div class="formcontent">
        <div class="basicInformation">
          <span>审定红线面积：{{numData.actualConstructionInformationInfoDTO.redLine}}公顷</span>
          <span>实际建设面积：{{numData.actualConstructionInformationInfoDTO.totalSize}}公顷</span>
          <span>实际整新增耕地总面积：{{numData.actualConstructionInformationInfoDTO.arableLandTotalArea}}公顷</span>
          <span>新增水田面积：{{numData.actualConstructionInformationInfoDTO.paddyFieldArea}}公顷</span>
        </div>
        <div class="basicInformation">
          <span>新增旱地面积：{{numData.actualConstructionInformationInfoDTO.dryLandArea}}公顷</span>
          <span>实际整新增整理耕地面积：{{numData.actualConstructionInformationInfoDTO.arrangeArableLandArea}}公顷</span>
          <span>实际整新增开发耕地面积：{{numData.actualConstructionInformationInfoDTO.developArableLandArea}}公顷</span>
          <span>实际整新增复垦耕地面积：{{numData.actualConstructionInformationInfoDTO.reclamationArableLandArea}}公顷</span>
        </div>
      </div>

      <div class="maintitle" style="margin:60px 0 30px 0;">市局意见</div>
      <div class="titleDeputy">经办人审查意见</div>
      <el-form-item>
        <el-input disabled v-model="form1.opinion" style="width:1000px;" type="textarea" rows="8"></el-input>
      </el-form-item>
      <div>
        <el-form-item label="审查人">
          <img style="width: 100px;" :src="`${baseUrl}${form1.signature}`" alt />
        </el-form-item>
        <el-form-item label="审查日期">
          <el-date-picker
            style="width:160px"
            disabled
            v-model="form1.createTime"
            type="date"
            placeholder="审查日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="审查意见">
          <el-select disabled v-model="form1.status" style="width:160px" placeholder="请选择">
            <el-option label="同意" :value="0"></el-option>
            <el-option label="拒绝" :value="1"></el-option>
          </el-select>
        </el-form-item>
      </div>
      <!-- <div class="titleDeputy">复核人审查意见</div>
      <el-form-item>
        <el-input disabled v-model="form2.opinion" style="width:1000px;" type="textarea" rows="8"></el-input>
      </el-form-item>
      <div>
        <el-form-item label="审查人">
          <img style="width: 100px;" :src="`${baseUrl}${form2.signature}`" alt />
        </el-form-item>
        <el-form-item label="审查日期">
          <el-date-picker
            disabled
            style="width:160px"
            v-model="form2.createTime"
            type="date"
            placeholder="审查日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="审查意见">
          <el-select disabled v-model="form2.status" style="width:160px" placeholder="请选择">
            <el-option label="同意" :value="0"></el-option>
            <el-option label="拒绝" :value="1"></el-option>
          </el-select>
        </el-form-item>
      </div>-->
      <div class="titleDeputy">处室负责人审查意见</div>
      <el-form-item>
        <el-input
          :disabled="disabled"
          v-model="form.opinion"
          style="width:1000px;"
          type="textarea"
          rows="8"
        ></el-input>
      </el-form-item>
      <div>
        <el-form-item label="审查人">
          <img style="width: 100px;" :src="`${baseUrl}${form.signature || signature}`" alt />
        </el-form-item>
        <el-form-item label="审查日期">
          <el-date-picker
            :disabled="disabled"
            style="width:160px"
            v-model="form.createTime"
            type="date"
            placeholder="审查日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="审查意见">
          <el-select
            :disabled="disabled"
            v-model="form.status"
            style="width:160px"
            placeholder="请选择"
          >
            <el-option label="同意" :value="0"></el-option>
            <el-option label="拒绝" :value="1"></el-option>
          </el-select>
        </el-form-item>
      </div>
      <!-- <div class="titleDeputy">中心领导审查意见</div>
      <el-form-item>
        <el-input type="textarea" :rows="6" placeholder v-model="textarea" style="width:1000px;"></el-input>
      </el-form-item>
      <div>
        <el-form-item label="审查人">
          <el-input style="width:160px" v-model="name1" size="small"></el-input>
        </el-form-item>
        <el-form-item label="审查日期">
          <el-date-picker type="date" v-model="name2" size="small" style="width:160px"></el-date-picker>
        </el-form-item>
        <el-form-item label="审查意见">
          <el-select size="small" style="width:160px" v-model="name3">
            <el-option value="1" label="同意"></el-option>
            <el-option value="2" label="拒绝"></el-option>
          </el-select>
        </el-form-item>
      </div>-->
      <div class="btn">
        <el-button v-if="!disabled" @click="addAdvice" type="primary">提交</el-button>
        <el-button v-if="!disabled">取消</el-button>
        <el-button v-if="disabled" @click="back">返回</el-button>
      </div>
    </el-form>
  </div>
</template>

<script>
import config from "@/config/index.js";
import moment from "moment";
import {
  getInvAndCon,
  getAdvice,
  addAdvice,
  getSignature
} from "@/api/completionAcceptance/cityComprehensiveOpinion.js";
export default {
  data() {
    return {
      numData: {
        projectInfoDTO: {},
        actualConstructionInformationInfoDTO: {}
      },
      form1: {
        signature: "",
        groupId: 20,
        projectId: localStorage.getItem("projectId"),
        type: 0,
        status: 0,
        opinion: "",
        createTime: ""
      },
      form2: {
        signature: "",
        groupId: 20,
        projectId: localStorage.getItem("projectId"),
        type: 1,
        status: 0,
        opinion: "",
        createTime: ""
      },
      form: {
        signature: "",
        groupId: 20,
        projectId: localStorage.getItem("projectId"),
        type: 2,
        status: 0,
        opinion: "",
        createTime: ""
      },
      baseUrl: config.baseUrlImg,
      signature: "",
      disabled: true,
      projectId: localStorage.getItem("projectId") || ""
    };
  },
  created() {
    if (this.$route.name === localStorage.getItem("key")) {
      this.disabled = false;
    }
    if (localStorage.getItem("lookStatus") == 2) {
      this.disabled = true;
    }
    this.getInvAndCon();
    this.getAdvice();
    // this.getAdvice1();
    this.getAdvice2();
    this.getSignature();
    this.getTime();
  },
  methods: {
    back() {
      this.$router.push("/projectManagement/projectImplementation/dealwith");
    },
    getTime() {
      var date = new Date();
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var day = date.getDate();
      if (month < 10) {
        month = "0" + month;
      }
      if (day < 10) {
        day = "0" + day;
      }
      var trueTime = year + "-" + month + "-" + day;

      this.form.createTime = trueTime;
    },
    getInvAndCon() {
      //获取基本数据信息
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      getInvAndCon({ projectId: this.projectId })
        .then(res => {
          loading.close();
          this.numData = res.data;
        })
        .catch(res => {
          loading.close();
        });
    },
    getAdvice() {
      //获取经办人审查意见
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      getAdvice({ projectId: this.projectId, groupId: 20, type: 0 })
        .then(res => {
          loading.close();
          if (res.data) {
            this.form1 = res.data;
          }
        })
        .catch(res => {
          loading.close();
        });
    },
    // getAdvice1() {
    //   //获取复核人审查意见
    //   const loading = this.$loading({
    //     lock: true,
    //     text: "Loading",
    //     spinner: "el-icon-loading",
    //     background: "rgba(0, 0, 0, 0.7)"
    //   });
    //   getAdvice({ projectId: this.projectId, groupId: 20, type: 1 })
    //     .then(res => {
    //       loading.close();
    //       if (res.data) {
    //         this.form2 = res.data;
    //       }
    //     })
    //     .catch(res => {
    //       loading.close();
    //     });
    // },
    getAdvice2() {
      //获取处室负责人审查意见
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      getAdvice({ projectId: this.projectId, groupId: 20, type: 2 })
        .then(res => {
          loading.close();
          if (res.data) {
            this.form = res.data;
          }
        })
        .catch(res => {
          loading.close();
        });
    },
    addAdvice() {
      //生成审查意见表
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      this.form.createTime = moment(this.form.createTime).format(
        "YYYY-MM-DD HH:mm:SS"
      );
      this.form.signature = this.signature;
      this.form.projectId = this.projectId;
      addAdvice(this.form)
        .then(res => {
          loading.close();
          this.$message({
            message: "提交成功！",
            type: "success"
          });
          this.getAdvice();
          this.$router.push(
            "/projectManagement/projectImplementation/dealwith"
          );
        })
        .catch(res => {
          loading.close();
        });
    },
    getSignature() {
      //获取用户签名
      getSignature().then(res => {
        this.signature = res.data;
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.maincontent {
  margin-top: 30px;
  padding: 30px 40px;
  background: #fff;
  height: auto;
  .maintitle {
    font-size: 18px;
    font-family: PingFang SC;
    font-weight: bold;
    line-height: 25px;
    color: #4d4d4d;
  }
  .formcontent {
    margin-top: 30px;
    .basicInformation {
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: 500;
      line-height: 20px;
      color: #8c8c8c;
      margin-bottom: 20px;
      span {
        margin-right: 60px;
      }
    }
  }
}
.titleDeputy {
  padding: 0 0 10px 0;
  font-size: 14px;
  font-family: PingFang SC;
  line-height: 25px;
  color: #4d4d4d;
}
</style>